package com.lvmama.pangolin.task;

import java.lang.reflect.Method;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import com.lvmama.pangolin.common.ClassLoaderCache;
import com.lvmama.pangolin.common.Constant;
import com.lvmama.pangolin.conf.ConfigManager;
import com.lvmama.pangolin.entity.ConvertTask;
import com.lvmama.pangolin.util.SpringContextUtil;


public class TicketProductParamHandlerTask {
	/**
	* @author zhoutianqi
	* @className TicketProductParamHandlerTask.java
	* @date 2017年6月6日 下午5:18:42
	* @description 
	*/
	private Logger logger = Logger.getLogger(getClass());
	@Autowired
	private ConfigManager configManager;
	@Autowired
	private SpringContextUtil springContextUtil;
	
	//@Scheduled(cron = "${Ticket_Product_Param_Handler_Cron}")
	public void scheduledMothod(){
		try {
			String[] ticketConfig = configManager.getParamValue(Constant.TICKET_PRODUCT_PARAM_TASK_CONFIG, Constant.TICKET_PRODUCT_PARAM_TASK_CONFIG).split(";");
			for(String item : ticketConfig){
				String[] infoConfig = configManager.getParamValue(item, item).split(";");
				Class<?> processClass = ClassLoaderCache
						.getClassByName(infoConfig[0]);
				Method method = processClass
						.getMethod(infoConfig[1]);
				method.invoke(springContextUtil.getBean(infoConfig[2]));
				logger.info("################## "+infoConfig[2]+"门票产品字段批处理任务分配完毕！");
			}
		} catch (Exception e) {
			logger.error("################## 门票产品字段Task异常："+e.getMessage());
		}
		
	}
}
